import { defHttp } from '@/utils/http/axios';
enum Api {
  getcodeAPI = '/sys/authorization/page',
  getItemApi = '/mc/dict/getItem',
  createAuthorizationApi = '/sys/authorization/createAuthorization',
}

//授权码
export function getcodeAPI(params) {
  params['current'] = params.page;
  params['size'] = params.pageSize;
  return defHttp
    .post(
      {
        url: Api.getcodeAPI,
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      const { records, total } = res.data;
      return {
        items: records, // 将数据列表赋值给 items
        total, // 直接使用 total
      };
    })
    .catch((err) => {
      console.log(err, '配置管理');
    });
}
//获取购买单位
export function getItemApi() {
  return defHttp
    .get(
      {
        url: Api.getItemApi + '?code=AUTHORIZATION_CODE_TYPE',
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    })
    .catch((err) => {
      console.log(err, '获取购买单位');
    });
}
export function createAuthorizationApi(params) {
  return defHttp
    .post(
      {
        url: Api.createAuthorizationApi,
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    })
    .catch((err) => {
      console.log(err, '配置管理');
    });
}
